#include <bits/stdc++.h>
#define endl '\n'
#define PII pair<int, int>
#define int long long
using namespace std;
const int N = 1e6 + 100;
double n, m, l, max_v;
struct detect{
	int x;
	double y, z, high, out;
}a[N];
struct detect_new{
	int fir, sec;
}cnt[N];
bool num[N];
double d[N];
void write (int x){
	cout << x;
	return ;
}
bool judge(int i){
	int k;
	if (a[i].z < 0)
		k = lower_bound(d + 1, d + 1 + (int)(m), a[i].high - 0.000000001) - d;
	else
		k = upper_bound(d + 1, d + 1 + (int)(m), a[i].high + 0.000000001) - d;
	// cout << a[i].out << endl;
	// cout << k << endl;
	if (d[k] < a[i].out && k != 0){
		return true;
	}else{
		return false;
	}
}
void solve(){
	cin >> n >> m >> l >> max_v;
	for (int i = 1; i <= n; i++){
		cin >> a[i].x >> a[i].y >> a[i].z;
		if (a[i].z < 0){
			if (a[i].y > max_v){
				a[i].high = a[i].x + 0.000000001;
			}else{
				a[i].high = -114514;
			}
			a[i].out = (a[i].y * a[i].y / 2 / a[i].z) * -1;
		}else if (a[i].z > 0){
			int k = ((max_v * max_v - a[i].y * a[i].y) / 2.0 / a[i].z);
			if (k < 0){
				a[i].high = a[i].x + 0.0000000001;
			}else{
				a[i].high = ((max_v * max_v - a[i].y * a[i].y) / 2.0 / a[i].z) + a[i].x;
			}
			a[i].out = l;
		}else{
			if (a[i].y > max_v){
				a[i].high = a[i].x + 0.0000000001;
			}else{
				a[i].high = -114514;
			}
			a[i].out = l;
		}
		// cout <<  << endl;
	}
	//accepted
	for (int i = 1; i <= m; i++){
		cin >> d[i];
	}
	sort (d + 1, d + 1 + (int)(m));
	int ans = 0;
	for (int i = 1; i <= n; i++){
		if (a[i].high < 0){
			// cout << "??\n";
			continue;
		}
		if (judge(i)){
			int u = lower_bound(d + 1, d + 1 + (int)(m), a[i].out - 0.000000001) - d;
			num[u] = true;
			// cout << "??\n";
			ans++;
		}
	}
	// cout << ans << ' ';
	//accepted
	ans = 0;
	for (int i = 1; i <= 1000000; i++){
		if (num[i]){
			ans++;
		}
	}
	cout << m - ans << endl;
}
signed main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	freopen ("detect.in", "r", stdin);
	freopen ("detect.out", "w", stdout);
	int t;
	cin >> t;
	while (t--){
		solve();
	}
	return 0;
}
